//
//  LiveClassRoomTableViewCell.m
//  AndCampus
//
//  Created by 史宵宵 on 2017/11/27.
//  Copyright © 2017年 史宵宵. All rights reserved.
//

#import "LiveClassRoomTableViewCell.h"

@interface LiveClassRoomTableViewCell ()

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *topheight;
@property (weak, nonatomic) IBOutlet UIImageView *playView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *payWidth;

@end

@implementation LiveClassRoomTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
//    self.topheight=0;

        // Initialization code
}
//- (void)setFrame:(CGRect)frame {
//    
//    if (frame.origin.x==0) {
//        frame.origin.x += 10;
//    }
//    if (frame.size.width == kScreenW) {
//        
//        frame.size.width -= 2 * 10;
//    }
//    
//    [super setFrame:frame];
//    
//}
- (void)setClassRoomInfo:(ClassRoomInfo *)classRoomInfo{
    if (![self.imageType isEqualToString:@"detail"]) {
        [self.liveImageView sd_setImageWithURL:[NSURL URLWithString:classRoomInfo.logo] placeholderImage:KLIVECLASSDEFAULT];
    }else{
        self.topheight.constant=0;
        self.playView.hidden=YES;
    }
    
    
    self.titleLabel.text = classRoomInfo.title;
    self.contentLabel.text = classRoomInfo.context;
    self.timeLabel.text = [NSString stringWithFormat:@"%@ 直播", classRoomInfo.live_begin_time];
    self.moneyLabel.text = [classRoomInfo.source_price isEqualToString:@"0"]? @"免费" : [NSString stringWithFormat:@"¥%@", classRoomInfo.source_price];
    
    self.moneyLabel.textColor = [classRoomInfo.source_price isEqualToString:@"0"]? KBACKNAVIGATIONCOLOR:[UIColor redColor];
    if (![self.imageType isEqualToString:@"detail"] && ![self.classRoomInfo.buyHistory isEqualToString:@"2"]) {
        self.payWidth.constant = 0;
        self.payButton.frame = CGRectZero;
    }else{
        self.payWidth.constant = 70;
    }
    [self setNeedsUpdateConstraints];
}
- (void)layoutSubviews
{
    [super layoutSubviews];
    
}

- (IBAction)pay:(id)sender {
    if (self.payLiveClassBlack) {
        self.payLiveClassBlack(self.classRoomInfo);
    }
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
